package com.ruoyi.web.controller.production;


import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mes.production.domain.SmesProductTech;
import com.ruoyi.mes.production.service.ISmesProductTechService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品工艺Controller
 *
 * @author simpsense
 * @date 2020-12-03
 */
@RestController
@RequestMapping("/production/productTech")
public class SmesProductTechController extends BaseController
{
    @Autowired
    private ISmesProductTechService smesProductTechService;

    /**
     * 查询产品工艺列表
     */
    @PreAuthorize("@ss.hasPermi('production:productTech:list')")
    @GetMapping("/list")
    public TableDataInfo list(SmesProductTech smesProductTech)
    {
        startPage();
        List<SmesProductTech> list = smesProductTechService.selectSmesProductTechList(smesProductTech);
        return getDataTable(list);
    }

    /**
     * 导出产品工艺列表
     */
    @PreAuthorize("@ss.hasPermi('production:productTech:export')")
    @Log(title = "产品工艺", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SmesProductTech smesProductTech)
    {
        List<SmesProductTech> list = smesProductTechService.selectSmesProductTechList(smesProductTech);
        ExcelUtil<SmesProductTech> util = new ExcelUtil<SmesProductTech>(SmesProductTech.class);
        return util.exportExcel(list, "productTech");
    }

    /**
     * 获取产品工艺详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:productTech:query')")
    @GetMapping(value = "/{smesProductTechNo}")
    public AjaxResult getInfo(@PathVariable("smesProductTechNo") String smesProductTechNo)
    {
        return AjaxResult.success(smesProductTechService.selectSmesProductTechById(smesProductTechNo));
    }

    /**
     * 新增产品工艺
     */
    @PreAuthorize("@ss.hasPermi('production:productTech:add')")
    @Log(title = "产品工艺", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmesProductTech smesProductTech)
    {
        return toAjax(smesProductTechService.insertSmesProductTech(smesProductTech));
    }

    /**
     * 修改产品工艺
     */
    @PreAuthorize("@ss.hasPermi('production:productTech:edit')")
    @Log(title = "产品工艺", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmesProductTech smesProductTech)
    {
        return toAjax(smesProductTechService.updateSmesProductTech(smesProductTech));
    }

    /**
     * 删除产品工艺
     */
    @PreAuthorize("@ss.hasPermi('production:productTech:remove')")
    @Log(title = "产品工艺", businessType = BusinessType.DELETE)
    @DeleteMapping("/{smesProductTechNos}")
    public AjaxResult remove(@PathVariable String[] smesProductTechNos)
    {
        return toAjax(smesProductTechService.deleteSmesProductTechByIds(smesProductTechNos));
    }
}